<template>
  <div id="app">
    <div class="container">
      <div class="close"><span class="iconfont iconicon-test"></span></div>
      <div class="logo"><span class="iconfont iconnew"></span></div>
      <div class="inputs">
        <myinput
          v-model="user.username"
          placeholder="请输入11位手机号"
          :reg="/^(\d{5,6})$|^(1\d{10})$/"
          :msg="'请输入正确手机号'"
        ></myinput>
        <myinput
          v-model="user.password"
          placeholder="请输入密码"
          type="password"
        ></myinput>
      </div>
      <p class="tips">
        没有账号？
        <a href="#/register" class="">去注册</a>
      </p>
      <mybutton type="success" @click="login">登录</mybutton>
    </div>
  </div>
</template>

<script>
import mybutton from "@/components/mybutton.vue";
import myinput from "@/components/myinput.vue";
import { userLogin } from "@/api/user.js";
export default {
  components: {
    mybutton,
    myinput,
  },
  data() {
    return {
      user: {
        username: "13307799079",
        password: "123456",
      },
    };
  },
  methods: {
    login() {
      if (
        /^[1][3,4,5,7,8][0-9]{9}$/.test(this.user.username) ||
        this.user.username === "test"
      ) {
        userLogin(this.user);
        console.log();
      } else {
        this.$toast.fail("请输入正确的账号或者密码");
      }
    },
  },
};
</script>

<style lang="less" scoped>
.container {
  padding: 20px;
}

.close {
  span {
    font-size: 27 / 360 * 100vw;
  }
}

.logo {
  display: flex;
  justify-content: center;

  span {
    display: block;
    font-size: 126 / 360 * 100vw;
    color: #d81e06;
  }
}

.inputs {
  input {
    margin-bottom: 20px;
  }
}

.tips {
  text-align: right;
  margin-bottom: 20px;

  a {
    color: #3385ff;
  }
}
</style>